package mrt.cse.tempworks.initialWorksOfTeamMembers.sumedha;

import org.apache.zookeeper.KeeperException;

import java.io.IOException;
import java.util.*;

public class Manager extends ClientHandler implements Runnable {

    public Manager(String name,String host,String zNode) {
        super.managerName = name;
        super.zNode = zNode;
        super.host = host;
    }

    public static void main(String[] args) {
        try{
            Random rm =  new Random();
            new Manager("Manager-"+rm.nextInt(10),"localhost:2181","zoo").run();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public void run() {
        try {
            connect(host);
            join(zNode, managerName);
            assignValues();
            synchronized (this) {
                while (!expired) {
                    wait();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }catch (KeeperException e) {
            e.printStackTrace();
        }
    }


}
